package com.acme.bankapp.domain.bank;

import com.acme.bankapp.service.bank.listeners.ClientRegistrationListener;

import java.util.ArrayList;
import java.util.Date;

public class Bank {
    private ArrayList<Client> clients = new ArrayList<Client>();
    private ArrayList<ClientRegistrationListener> listeners = new ArrayList<ClientRegistrationListener>();

    public Bank() {
        class DebugListener implements ClientRegistrationListener {
            public void onClientAdded(Client client) {
                System.out.println(client.getName() + " " + new Date());
            }
        }
        listeners.add(new DebugListener());
    }

    public void addClient(Client client) {
        clients.add(client);
        for (ClientRegistrationListener listener : this.listeners) {
            listener.onClientAdded(client);
        }
    }

    public ArrayList<Client> getClients() {
        return clients;
    }


}
